<?php
    header('Access-Control-Allow-Origin: *');
    header('Content-Type:text/html;charset=utf-8');
    $con = mysqli_connect("127.0.0.1", "root", "root", "mydb");
    $uid = $_GET['uid'];
    $classId = $_GET['classId'];
    // echo $uid.'-'.$classId;
    $sql = "SELECT * FROM lessonstu WHERE l_id = '$classId' AND s_id = '$uid';";
    $res = mysqli_query($con,$sql);
    if(mysqli_fetch_row($res)){
        echo 'exist';
    }else{
        $sql1 = "INSERT INTO lessonstu (s_id,l_id) VALUES('$uid','$classId');";
        $res1 = mysqli_query($con,$sql1);
        if(mysqli_affected_rows($con) > 0){
            echo 'ok';
        }else{
            echo 'fail';
        }
    }
    mysqli_close($con);
?>